// mykill.cc
#include <iostream>
#include <signal.h>
#include <stdlib.h>
#include <unistd.h>

void usage(const char *proc)
{
    std::cout << "Usage: " << proc << " -signum pid" << std::endl;
}

int main(int argc, char *argv[])
{
    if (argc != 3)
    {
        usage(argv[0]);
        exit(1);
    }

    int signum = atoi(argv[1] + 1); // argv[1] is "-9", +1 skips '-'
    pid_t pid = atoi(argv[2]);

    if (kill(pid, signum) == 0)
    {
        std::cout << "Signal " << signum << " sent to PID " << pid << " successfully." << std::endl;
    }
    else
    {
        perror("kill");
    }

    return 0;
}